<template>
  <div class="list">
    <!-- <div class="list-top">
           <div class="top-content">
               <h3></h3>
           </div>
    </div>-->
    <div class="list-item">
      <div class="content" v-for="(item ,index) in contentItem" :key="item.id">
        <div class="imgs">
          <img
            :src="item.pic"
            alt
          />
        </div>
        <span class="names">{{item.name}}</span>
        <p class="text">{{item.characteristic}}</p>
        <p class="price">{{item.minPrice | currency }}</p>
        <button  @click="intDetail(index,item.id)">立即购买</button>
      </div>
    </div>
  </div>
</template>

<script>
import { currency } from 'utils/filter'
export default {
  props: {
    contentItem: {
      type: Array,
      required: true
    }
  },
  filters: {
    currency
  },
  methods: {
    intDetail (index, id) {
      this.$emit('intDetail', { index, id })
    }
  }
}
</script>

<style lang="scss" scoped>
.list {
  width: 100%;
}
.list-item {
  display: flex;
  flex-wrap: wrap;
}
.content {
  width: 50%;
  .imgs {
    img {
      width: 80%;
      display: block;
      margin: 0 auto;
    }
  }
  .names{
      display: block;
     text-align: center;
  }
  .text, .price{
    font-size: 14px;
    color: #666;
     text-align: center;
     padding: 0 20%;
     white-space: nowrap;
     overflow: hidden;
     text-overflow: ellipsis;
    margin-block-start: 2px;
    margin-block-end: 2px;
    margin-inline-start: 2px;
    margin-inline-end: 2px;
  }
  .price{
      color: red;
      line-height: 1;
  }
  button{
       background-color: red;
       border-radius: 5px;
       color: white;
       margin: 0 25% 10px;
  }
}
</style>
